package com.shakev.coupon.data.mysql.controller;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shakev.coupon.business.service.CategoryBusiService;
import com.shakev.coupon.business.util.JsonUtils;
import com.shakev.coupon.business.util.rest.RestResponse;
import com.shakev.coupon.data.mysql.entity.HotSearch;
import com.shakev.coupon.data.mysql.service.IHotSearchService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lws
 * @since 2019-06-13
 */
@RestController
public class HotSearchController {
    @Resource
    IHotSearchService hotSearchService;

    @GetMapping("/hotSearch/keywords")
    public RestResponse keywords(){

        QueryWrapper<HotSearch> query = new QueryWrapper<>();
        query.eq(true,"is_delete",0);
//        query.orderByDesc(true,true,"order_by");
        List<HotSearch> list = hotSearchService.list(query);
        List<String> res = new ArrayList<>();
        if (list!=null && list.size()>0){
            for (HotSearch hotSearch : list) {
                res.add(hotSearch.getKeywords());
            }
        }
        return RestResponse.success(res);
    }
}
